package mystatic.src.PC;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CardDemo {
    String[] suit={"♥","♠","♣","♦"};


    public List<Card> buyCard(List<Card> cards){
        for(int i=1;i<=12;i++){
            for(int j=0;j<suit.length;j++){
                Card card=new Card(i,suit[j]);
                cards.add(card);
            }
        }
        return cards;
    }

    public List<Card> shuffle(List<Card> cards){
        Random random=new Random();
        for(int i=0;i<cards.size();i++){
            int j=random.nextInt(cards.size());
            Card card=cards.get(i);
            cards.set(i,cards.get(j));
            cards.set(j,card);
        }
        return cards;
    }

    public List<List<Card>> Assign(List<Card> cards){
        List<List<Card>> hand=new ArrayList<>();
        List<Card> hand0=new ArrayList<>();
        List<Card> hand1=new ArrayList<>();
        List<Card> hand2=new ArrayList<>();
        hand.add(hand0);
        hand.add(hand1);
        hand.add(hand2);
        for(int i=0;i<3;i++){
            for(int j=0;j<5;j++){
                Card card=cards.remove(0);
                hand.get(i).add(card);
            }
        }
        return hand;
    }

}
